package com.java.al.swing.toolbar.toolbar;


import java.awt.BorderLayout;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JToolBar;

public class ToolbarMoreTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		final JFrame frame = new JFrame();
		JToolBar toolbar = new JToolBar();
		for (int i = 0; i < 20; i++) {
			final JButton btn = new JButton(i + "");
			AbstractAction ac = new AbstractAction("" + i, new ImageIcon(ToolbarMoreTest.class.getResource(i + ".gif"))) {
				public void actionPerformed(ActionEvent e) {
					JOptionPane.showMessageDialog(frame, btn.getText());
				}
			};
			toolbar.add(ac);
		}
		JPanel centerPanel = new JPanel(new BorderLayout());
		centerPanel.add(new JScrollPane(new JTextArea()));
		centerPanel.add(MoreButton.wrapToolBar(toolbar), BorderLayout.NORTH);
		frame.setContentPane(centerPanel);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLocationRelativeTo(null);
		frame.setSize(500, 400);
		frame.setVisible(true);
	}
}
